#include<stdio.h>
#include<assert.h>
int my_strlen(const char* str) {
	assert(str != NULL);
	char* p=str;
	while (*p) {
		p++;
	}
	return p - str;
}
char* my_strcpy(const char* src, char* dst) {
	assert(src != NULL);
	assert(dst != NULL);
	char* ret = dst;
	while (*dst++ = *src++);
	return ret;
}
int my_strcmp(const char* str1, const char* str2) {
	assert(str1 != NULL);
	assert(str2 != NULL);
	int ret = 0;
	const unsigned char* s1 = (const unsigned char*)str1;
	const unsigned char* s2 = (const unsigned char*)str2;
	while (!(ret = *s1 - *s2) && *s1)
		s1++, s2++;
	if (ret > 0) {
		return 1;
	}
	else if (ret < 0) {
		return -1;
	}
	else
		return 0;
}
char* my_strcat(char* dst, const char* src) {
	assert(dst != NULL);
	assert(src != NULL);
	char* ret = dst;
	while (*dst) {
		dst++;
	}
	while (*dst++ = *src++);
	return ret;
}
char* my_strstr(const char* str1, const char* str2) {
	assert(str1 != NULL);
	assert(str2 != NULL);
	const char* s1 = str1; 
	const char* s2 = str2;
	const char* move=NULL;
	if (!*str2) {
		return s1;
	}
	while (*s1) {
		str2 = s2;
		move = s1;
		while (*str2 && *move && *str2++ == *move++) {
			if (!*str2) { 
				return s1;
			}
		}
		s1++;
		
	}
	return NULL;
}
void* my_memcpy(void* dst, const void* src, size_t count) {
	assert(dst != NULL);
	assert(src != NULL);
	void* ret = dst;
	if (!count) {
		return dst;
	}
	unsigned char* _dst =(unsigned char*) dst;
	unsigned char* _src = (unsigned char*)src;
	while (count--) {
		*_dst++ = *_src++;
	}
	return ret;
}

